<template>
	<view>
		<view class="grayBox"></view>
		<view class="menu">
			<navigator class="borderBottom" url="/modules/message/tzList">
				<view>
					<image src="../../static/tz.png"></image>
					<text>公告</text>
					<text v-text="unReadNum" v-if="unReadNum"></text>
				</view>
			</navigator>
			<navigator class="borderBottom" url="/modules/message/xtxxList">
				<view>
					<image src="../../static/xtxi.png"></image>
					<text>系统消息</text>
					<text v-text="sysMsgUnReadNum" v-if="sysMsgUnReadNum"></text>
				</view>
			</navigator>
		</view>
	</view>

</template>

<script>
	import {format} from '../../libs/common.js';
	export default {
		data() {
			return {
				unReadNum: "",
				sysMsgUnReadNum: ""
			};
		},
		onShow() {
			this.getDetail()
			this.fetchSysMsgCountUnReadNum();
			this.getRedDotStatus()
		},
		methods: {
			async getRedDotStatus(){
				let notice = await this.$http.get({url: '/oa/notification/weChat/loginUserUnReadStatus'})
				let sysMessage = await this.$http.get({url: '/oa/sysMessage/loginUserUnReadStatus'})
				if(notice.result || sysMessage.result){
					uni.showTabBarRedDot({
						index:1
					})
				}else{
					uni.hideTabBarRedDot({
						index:1
					})
				}
			},
			//获取通知气泡数
			async getDetail(id) {
				let resp = await this.$http.get({
					url: '/oa/notification/weChat/loginUserUnReadNum'
				});
				this.unReadNum = resp.result
			},
			async fetchSysMsgCountUnReadNum() {
				let resp = await this.$http.get({
					url: '/oa/sysMessage/countUnReadNum'
				});
				this.sysMsgUnReadNum = resp.result
			}
		}
	};
</script>

<style lang="scss" scoped>
	.menu {
		padding: 0 50upx;

		navigator {
			height: 80upx;
			line-height: 80upx;
			justify-content: space-between;
			align-items: center;
			display: flex;

			view {
				display: flex;
				align-items: center;
			}

			image {
				width: 42upx;
				height: 42upx;
				margin-right: 20upx;
			}

			text {
				&:nth-of-type(2) {
					min-width: 28upx;
					height: 28upx;
					background: rgba(255, 83, 74, 1);
					border-radius: 14upx;
					margin-left: 20upx;
					font-size: 22upx;
					font-family: Arial;
					font-weight: 400;
					color: rgba(255, 255, 255, 1);
					display: inline-block;
					text-align: center;
					line-height: 28upx;
					padding: 0 8upx;
				}

			}
		}

		.tit {
			display: flex;
			justify-content: space-between;

			text {
				font-size: 28upx;
				line-height: 100upx;
				font-weight: 600;
			}
		}
	}

	.grayBox {
		width: 100%;
		height: 20upx;
		background: #F2F4F5;
	}
</style>
